<template>
	<view class="complaint-list">
		<view class="title-info">
			<view class="line"></view>
			<view class="title">投诉举报记录</view>
		</view>
		<template v-if="list.length>0">
			<view class="info-list" v-for="item in list" :key="item.id"
				@click="navigate('/page_pack/complaint/detail?id='+item.id)">
				<view class="name">{{item.sketch}}</view>
				<view class="time-item">
					<view class="time">{{item.createTime}}</view>
					<view class="status orange" v-if="item.isReply==0">待核实</view>
					<view class="status green" v-else>已处理</view>
				</view>
			</view>
		</template>
		<view v-if="more==false&&list.length==0" class="empty">暂无数据</view>
		<view v-else-if="more==false&&list.length>0" class="empty">没有更多了</view>
		<view class="btn-item" @click="navigate('/page_pack/complaint/complaint')">
			<view class="btn normal">
				<view class="iconfont icon-jia"></view>投诉举报
			</view>
		</view>
	</view>
</template>

<script>
	import {
		isMore
	} from '@/util/util.js'
	import {
		getReportListApi
	} from '@/api/complaint.js'
	export default {
		data() {
			return {
				list: [{
						id: 1,
						name: '发现XX⼩区X号楼X单元X室的保障性住房被转租',
						time: '2025-02-23 15:30',
						status: 1
					},
					{
						id: 2,
						name: '发现XX⼩区X号楼X单元X室的保障性住房被转租',
						time: '2025-02-23 15:30',
						status: 2
					}
				],
				more: true,
				conf: {
					page: 1,
					limit: 10
				},
				//list: []
			}
		},
		methods: {
			handleRefresh() {
				this.conf.page = 1;
				this.more = true
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				this.getList(true)
			},
			getList(refresh = false) {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getReportListApi({
					page: this.conf.page,
					limit: this.conf.limit
				}).then(res => {
					console.log(res)
					let list = res.records || [];
					if (refresh) {
						this.list = list;
					} else {
						this.list = [...this.list, ...list]
					}
					this.more = isMore(this.conf.page, this.conf.limit, res.total)
				})
			},
			onReachBottom() {
				if (this.more) {
					this.conf.page++;
					uni.showLoading({
						title: '加载中',
						mask: true
					})
					this.getList();
				}
			},
		},
		onLoad() {
			this.getList(true)
		},
	}
</script>

<style lang="scss" scoped>
	.complaint-list {
		padding: 30rpx;

		.title-info {
			display: flex;
			align-items: center;
			margin-bottom: 30rpx;

			.line {
				width: 18rpx;
				height: 36rpx;
				background-color: $theme-color;
				border-radius: 40rpx;
				margin-right: 14rpx;
			}

			.title {
				font-size: 32rpx;
				font-weight: bold;
			}
		}

		.info-list {
			background-color: #fff;
			padding: 30rpx;
			margin-bottom: 30rpx;
			border-radius: 30rpx;

			.name {
				font-size: 32rpx;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
			}

			.time-item {
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-top: 30rpx;

				.time {
					font-size: 28rpx;
					color: #767676;
				}

				.status {
					font-size: 28rpx;
				}

				.green {
					color: #18aa00;
				}

				.orange {
					color: #ffa100;
				}
			}
		}

		.btn-item {
			display: flex;
			align-items: center;
			justify-content: center;

			.btn {
				width: 400rpx;
				display: flex;
				align-items: center;

				.iconfont {
					margin-right: 20rpx;
					font-size: 30rpx;
				}
			}
		}
	}
</style>